var data = [
    { "ID": "B01", "BoatNo": "HUAYUAN001", "BoatName": "华远001", "Status": "在气田", "materialname": "食品", "toplace": "HZ876", "eta": "100", "draft": "29", "dieseloil": "218", "water": "233", "megbalance": "877" },
    { "ID": "02", "BoatNo": "HYSY685", "BoatName": "海洋石油685", "Status": "返航途中", "materialname": "食品", "toplace": "HZ876", "eta": "100", "draft": "29", "dieseloil": "218", "water": "233", "megbalance": "877" },
    { "ID": "03", "BoatNo": "HYSY651", "BoatName": "海洋石油651", "Status": "在港", "materialname": "食品", "toplace": "HZ876", "eta": "100", "draft": "29", "dieseloil": "218", "water": "233", "megbalance": "877" },
    { "ID": "04", "BoatNo": "DETAO", "BoatName": "德涛", "Status": "返航途中", "materialname": "食品", "toplace": "HZ876", "eta": "100", "draft": "29", "dieseloil": "218", "water": "233", "megbalance": "877" },
    { "ID": "05", "BoatNo": "DEPEI", "BoatName": "德沛", "Status": "在气田", "materialname": "食品", "toplace": "HZ876", "eta": "100", "draft": "29", "dieseloil": "218", "water": "233", "megbalance": "877" }
];

// 用户ID
let id = getUrlParam("id");
$(function () {
    GetUserRole();
});
//获取用户权限
function GetUserRole() {
    // let thisdata = [];
    // thisdata.push(InitRole(id));
    let USERdata = InitRole(id);
    if (USERdata != null) {
        choose('sh');
        InitData();
    }
    else OpenErrmsg("../../web/errhtml/404.html");
}
function dialog() {
    var div = document.createElement('div');
    div.setAttribute('id', 'div')
    var element = document.getElementsByTagName('body')[0];
    element.appendChild(div);
    //
    //Failed to load https://www.baidu.com/?_=1545205422040: 
    //No 'Access-Control-Allow-Origin' header is present on the requested resource. 
    //Origin 'null' is therefore not allowed access.跨越问题
    $('#div').dialog({
        href: './dialog',
        title: 'My Dialog',
        width: 400,
        height: 200,
        left: '20%',
        right: '20%',
        closed: false,
        cache: false,
        zIndex: 10000,
        modal: true,
        title: "新增航运动态",
        iconCls: '',
        // buttons: [{
        //     text: '提交',
        //     iconCls: 'icon-ok',
        //     handler: function () {
        //         alert('确认提交？');
        //     }
        // }, {
        //     text: '取消',
        //     handler: function () {
        //         alert('确认取消？');
        //     }
        // }],
        // 居中
        onResize: function () {
            $(this).dialog('center');
        }
    });
}
function choose(type) {
    $('#btn_sh').removeClass("labelstyleChoose labelstyle");
    $('#btn_ty').removeClass("labelstyleChoose labelstyle");
    $('#btn_ys').removeClass("labelstyleChoose labelstyle");
    $('#btn_fj').removeClass("labelstyleChoose labelstyle");

    $('#btn_sh').addClass(type == "sh" ? "labelstyleChoose" : "labelstyle");
    $('#btn_ty').addClass(type == "ty" ? "labelstyleChoose" : "labelstyle");
    $('#btn_ys').addClass(type == "ys" ? "labelstyleChoose" : "labelstyle");
    $('#btn_fj').addClass(type == "fj" ? "labelstyleChoose" : "labelstyle");
    InitData(type);
}
// 重置按钮
function ReInitData() {
    $('#db_Start').datebox('setValue', GetDateStr(-7));
    $('#db_End').datebox('setValue', getCurrDate());
    InitData();
}
function chooseSearch() {
    var isok = $("#ck_search").is(':checked');
    if (isok) {
        $("#div_Search").show();
        $('#db_Start').datebox('setValue', GetDateStr(-7));
        $('#db_End').datebox('setValue', getCurrDate());
    }
    else {
        $("#div_Search").hide();
        $('#db_Start').datebox('setValue', "");
        $('#db_End').datebox('setValue', "");
    }
}
function InitData() {
    $('#dg_WorkPlanList').datagrid({
        data: data,
        onLoadSuccess: function (data) {
            $("#tb01").css("background-color", "white");
        }
    });
}

